package dungnt.vpoint.mathtest;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
import android.content.Intent;

public class PlayActivity extends Activity implements OnClickListener{
    private Button btnAdd;
    private Button btnSubtract;
    private Button btnMultiply;
    private Button btnDivide;
    private Button btnFinalTest;
    private Intent i_gamemode;
    
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.activity_play);
		
		btnAdd = (Button)findViewById(R.id.btnAdd);
		btnSubtract = (Button)findViewById(R.id.btnSubtract);
		btnMultiply = (Button)findViewById(R.id.btnMultiply);
		btnDivide = (Button)findViewById(R.id.btnDivide);
		btnFinalTest = (Button)findViewById(R.id.btnFinalTest);
		
		btnAdd.setOnClickListener(this);
		btnSubtract.setOnClickListener(this);
		btnMultiply.setOnClickListener(this);
		btnDivide.setOnClickListener(this);
		btnFinalTest.setOnClickListener(this);
	}

	
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.btnAdd:
            i_gamemode = new Intent(this, GameMode.class);
            i_gamemode.putExtra("operator", "0");
            startActivity(i_gamemode);
            break;
        case R.id.btnSubtract:
            i_gamemode = new Intent(this, GameMode.class);
            i_gamemode.putExtra("operator", "1");
            startActivity(i_gamemode);
            break;
        case R.id.btnMultiply:
            i_gamemode = new Intent(this, GameMode.class);
            i_gamemode.putExtra("operator", "2");
            startActivity(i_gamemode);
            break;
        case R.id.btnDivide:
            i_gamemode = new Intent(this, GameMode.class);
            i_gamemode.putExtra("operator", "3");
            startActivity(i_gamemode);
            break;
        case R.id.btnFinalTest:
            i_gamemode = new Intent(this, GameMode.class);
            i_gamemode.putExtra("operator", "4");
            startActivity(i_gamemode);
            break;
        }
    }
    
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            Intent i = new Intent(this, MainActivity.class);
            startActivity(i);
            finish();
        }
        
        return super.onKeyDown(keyCode, event);
    }

}
